package pl.owm.main;

import java.io.File;
import java.util.Calendar;
import java.util.List;

import com.osp.ProjectManager;
import com.osp.model.Employee;
import com.osp.model.Task;

import pl.owm.readxls.FileReader;
import pl.owm.readxls.FileReader.TaskRow;

public class ModelCreator {
	
	File root;
	
	public ModelCreator(String path){
		root = new File(path);
	}
	
	public ModelCreator(){
		root = new File("reporter-test2");
	}
	
	
	
	public ProjectManager createModel(){
		FileReader fileReader = new FileReader();
		List<TaskRow> tasks = fileReader.getTasks(root);
		
		ProjectManager projectManager = new ProjectManager();
		
		
		//add employees
		for(TaskRow task : tasks){

			Employee e = new Employee(task.getEmployee());
			projectManager.addEmployee(e);
			for(Employee emp :	projectManager.getEmployees()){
				if(emp.equals(e)){
					emp.addTask(new Task(task.getDate(), task.getTask(), task.getLength(), task.getProject()));
				}
			}
		}
		
		return projectManager;
	
	}
	

}
